/**
  * <br>JAVACC DEMO 1.0<br>
  * @copy right dwusoft company All rights reserved.<br>
  * <br>
  * @Package com.apache.dict.service.helper
*/
package com.apache.info.service;

import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.ContextRefreshedEvent;

import com.apache.database.db.IDao;

/**
  * description: 系统启动初始化缓存
  * @author Hou DaYu 创建时间：下午02:14:42
  */
public class InfoMetadataListener implements ApplicationListener<ApplicationEvent> {

	public static boolean isStart = false;
	private IDao pubMetadataDao;

	public void onApplicationEvent(ApplicationEvent event) {
		if (isStart)
			return;

		if (event instanceof ContextClosedEvent) {//当ApplicationContext关闭时触发该事件

		} else if (event instanceof ContextRefreshedEvent) {//当ApplicationContext初始化或者刷新时触发该事件
			if (event.getTimestamp() > 0) {
				pubMetadataDao.initSystemCache();
			}
		}
		isStart = true;
	}

	public void setPubMetadataDao(IDao pubMetadataDao) {
		this.pubMetadataDao = pubMetadataDao;
	}
}
